﻿using System;
using System.Collections;
namespace Gaming
{
    public struct BitSet
    {
        private int _state;

        public BitSet(int mask)
        {
            _state = mask;
        }

        public bool Get(int mask)
        {
            return 0!=(_state & mask);
        }

        public bool Set(int mask, bool on)
        {
            bool was = Get(mask);
            if (on)
                _state |= mask;
            else
                _state &= ~mask;
            return was;
        }

        public int ToInt() { return _state; }

    }
}